/**
 * @Author：ming
 * @Date：2023/9/26 7:13 PM
 * @Filename：Lc108
 */

/**
 * @author ming
 */
public class Lc108 {
    public TreeNode sortedArrayToBST(int[] nums) {
        return sortedTree(nums,0,nums.length-1);
    }

    public TreeNode sortedTree(int[] nums,int left,int right){
        if(left>right){
            return null;
        }



        int mid =(left+right)/2;

        TreeNode treeNode = new TreeNode(nums[mid]);
        treeNode.left = sortedTree(nums,left,mid-1);
        treeNode.right = sortedTree(nums,mid+1,right);

        return treeNode;

    }
}
